package com.lap.web.starter.api.builder;

import com.lap.context.starter.core.helper.SpringHelper;
import com.lap.web.starter.api.ApiResource;
import java.util.List;
import lombok.experimental.UtilityClass;
import org.springframework.web.bind.annotation.RestController;

@UtilityClass
public class ApiScanner {

  public List<ApiResource> scan(String module, String name) {
    List<Object> sources =
        SpringHelper.getBeans(
            RestController.class,
            List.of(
                "org.springdoc.webmvc.api.OpenApiWebMvcResource",
                "org.springdoc.webmvc.ui.SwaggerConfigResource"));
    return new ApiDirector(new DefaultBuilder()).construct(module, name, sources);
  }
}
